﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02_RectangleDemo
{
    class Rectangle
    {
        // 成员变量
        double width;
        double height;

        // 带参数的构造函数
        public Rectangle(double width, double height) 
        {
            this.width = width;
            this.height = height;
            Console.WriteLine("生成一个矩形");
        }

        // 无参构造函数
        public Rectangle() 
        {
            Console.WriteLine("生成一个矩形");
        }

        public double GetWidth()
        {
            return width;
        }
        public double GetHeight() 
        { 
            return height;
        }
        public void SetWidth(double width) 
        { 
            this.width=width;
        }
        public void SetHeight(double height)
        {
            this.height = height;

        }

        public void PrintInfo()
        {
            Console.WriteLine("矩形的宽为：{0}", width);
            Console.WriteLine("矩形的长为：{0}", height);
        }

    }


    internal class Program
    {
        static void Main(string[] args)
        {
            Rectangle r = new Rectangle();
            r.SetWidth(10);
            r.SetHeight(20);
            r.PrintInfo();
            Console.ReadKey();
        }
    }
}
